﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Drawing.Drawing2D;

namespace UpFile
{
    public partial class ShowPhoto : Form
    {
        private string strurl;
        string strname = "";
        public ShowPhoto()
        {
            InitializeComponent();
        }
        public ShowPhoto(string strUrl, string name)
        {
            this.strurl = strUrl;
            this.strname = name;
            InitializeComponent();
        }

        private void ShowPhoto_Load(object sender, EventArgs e)
        {
            WebClient wc = new WebClient();
            Stream sr = wc.OpenRead(strurl);
            Bitmap bt = new Bitmap(sr);
            bt = KiResizeImage(bt, 781, 420);
            sr.Close();
            pictureBox1.Image = bt;
        }

        public static Bitmap KiResizeImage(Bitmap bmp, int newW, int newH)
        {
            try
            {
                Bitmap b = new Bitmap(newW, newH);
                Graphics g = Graphics.FromImage(b);
                // 插值算法的质量
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.DrawImage(bmp, new Rectangle(0, 0, newW, newH), new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);
                g.Dispose();
                return b;
            }
            catch
            {
                return null;
            }
        }


    }
}
